;
(function () {
    var define;
    var defineRec = {}; //对象

    var require;
    var requireRec = []; //数组对象

    // 定义一个person
    define = function (name, factory) {
        defineRec[name] = {
            name: name,
            factory: factory
        }
    }


    // Person的构造函数
    function Person(name, age) {
        this.name = name;
        this.age = age;
        if (typeof Person.prototype.sayHi != "function") {
            Person.prototype.sayHi = function () {
                console.log("hi, i'm " + this.name);
            }
        }
    }

    define('wzq', function () {
        return new Person('wzq', 31);
    });

    require = function (name) {
        if (!defineRec[name]) {
            throw 'name=' + name + " not found";
        }

        //
        else if (defineRec[name].factory) {
            // TODO
            return build(defineRec[name]);
        }
    }

    function build(module) {
        return module.factory();
    }
})();
